package com.lam.mall.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.lam.common.base.controller.BaseController;
import com.lam.common.base.domain.Result;
import com.lam.common.components.dict.annotation.DictAutoTransfer;
import com.lam.framework.annotation.ParamInject;
import com.lam.framework.operLog.annotation.Log;
import com.lam.mall.entity.OrderItem;
import com.lam.mall.param.OrderItemParam;
import com.lam.mall.service.OrderItemService;

/**
 * 订单项Controller
 * 
 * @author admin
 * @date 2023-04-25
 */
@Log(title = "订单项")
@ParamInject
@RestController
@RequestMapping("/${adminPath}/mall/orderItem")
public class OrderItemController extends BaseController {

    @Autowired
    private OrderItemService orderItemService;

    /**
     * 查询订单项列表
     */
    @Log(oper="分页查询")
    @DictAutoTransfer
    @PreAuthorize("@ss.hasPm('mall:orderItem:list')")
    @GetMapping("/list")
    public Result list(OrderItemParam param) {
    
        startPage();
        List<OrderItem> list = orderItemService.selectList(param);
        return Result.ok(getTableData(list));
    }

    /**
     * 获取订单项详细信息
     */
    @DictAutoTransfer
    @Log(oper="根据ID查询")
    @PreAuthorize("@ss.hasPm('mall:orderItem:query')")
    @GetMapping("/{orderItemId}")
    public Result getInfo(@PathVariable("orderItemId") String orderItemId) {
    
        return Result.ok(orderItemService.selectById(orderItemId));
    }

}
